import Vue from 'vue'
import Router from 'vue-router'
// import Layout from '@/views/layout'
Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: () => import('@/views/layout'),
    redirect: '/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/index/index')
      },
      //  工单管理
      {
        path: 'order',
        component: () => import('@/views/order/index')
      },
      {
        path: 'OperationAndMaintenanceWorkOrder',
        component: () => import('@/views/OperationAndMaintenanceWorkOrder')
      },
      {
      // 点位管理
        path: 'RegionalManagement',
        component: () => import('@/views/RegionalManagement')
      },
      {
        path: 'PointManagement',
        component: () => import('@/views/PointManagement')
      },
      {
        path: 'PartnerManagement',
        component: () => import('@/views/PartnerManagement')
      },
      //  设备管理
      {
        path: 'deviceManagement',
        component: () => import('@/views/deviceManagement')
      },
      {
        path: 'DeviceStatus',
        component: () => import('@/views/DeviceStatus')
      },
      {
        path: 'DeviceTypeManagement',
        component: () => import('@/views/DeviceTypeManagement')
      },
      //  人员管理
      {
        path: 'PersonnelList',
        component: () => import('@/views/PersonnelList')
      },
      {
        path: 'HumanEfficiencyStatistics',
        component: () => import('@/views/HumanEfficiencyStatistics')
      },
      {
        path: 'WorkloadList',
        component: () => import('@/views/WorkloadList')
      },
      //  商品管理
      {
        path: 'ProductType',
        component: () => import('@/views/ProductType')
      },
      {
        path: 'Commodity',
        component: () => import('@/views/Commodity')
      },
      //  策略管理
      {
        path: 'tactics',
        component: () => import('@/views/tactics')
      },

      //  战略管理
      {
        path: 'strategicManagement',
        component: () => import('@/views/strategicManagement')
      },
      //  订单管理
      {
        path: 'OrderManagement',
        component: () => import('@/views/OrderManagement')
      },
      //  对账统计
      {
        path: 'ReconciliationStatistics',
        component: () => import('@/views/ReconciliationStatistics')
      }
    //  ReconciliationStatistics
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
